<template>
	<view class="container">
		<view class="current_city">
			<view class="title">當前城市</view>
			<view class="city_name" style="color: #39B19D;">{{currentCity}}</view>
		</view>
		<view class="open_city">
			<view class="title">已開通城市</view>
			<view class="city_name" v-for="item in openCity" :key="item.id" @tap="select_city(item)" >{{item.name}}</view>
		</view>
	</view>
</template>

<script>
	import store from "@/store/index.js"
	import {getOpenCity} from '@/api/index.js'
	
	export default {
		data() {
			return {
				currentCity: "",
				openCity: []
			};
		},
		onLoad(option) {
			// console.log(option, "查看option")
			this.currentCity = option.city

			// uni.request({
			// 	url: this.env + "/index/getCitys",
			// 	success:(res)=>{
			// 		this.openCity = res.data.data
			// 		console.log(this.openCity)
			// 	}
			// })
			getOpenCity().then(res=>{
				this.openCity = res.data
			})
		},
		methods:{
			select_city(item){
				this.$store.commit("select_city",item)
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="less">
	.container {
		background: #F3F5F9;
		height: calc(100vh - 90rpx);
		padding: 30rpx;
		box-sizing: border-box;

		.current_city,
		.open_city {
			border-bottom: 1rpx solid #f0f0f0;
			margin-bottom: 30rpx;

			.title {}

			.city_name {
				display: inline-block;
				// padding: 10rpx 20rpx;
				background: #fff;
				border-radius: 16rpx;
				width: 150rpx;
				height: 50rpx;
				text-align: center;
				line-height: 50rpx;

				margin: 20rpx;
			}
		}




	}
</style>